package domain;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public abstract class TrafficInfrastructure {
	protected TrafficInfrastructure(String id){
		this.id = id;
	}
	
	
	public void subscribeTrafficObserver(TrafficObserver obs) {
		observers.add(obs);
	}
	
	public void unsubscribeTrafficObserver(TrafficObserver obs) {
		observers.remove(obs);
	}
	
	public interface TrafficObserver {
		void notifyTrafficChange();
	}
	
	protected void notifyObservers() {
		for(TrafficObserver obs : observers) {
			obs.notifyTrafficChange();
		}
	}
	
	private Set<TrafficObserver> observers = new HashSet<TrafficObserver>();
	
	/* **** id *** */
	
	private final String id;
	public String getId() {
		return id;
	}
	
	@Override
	public String toString() {
		return getId();
	}
	
	/* *** lengte *** */
	public abstract int getLength();
	
	/* *** segmenten van de infrastructuur *** */
	public abstract boolean hasSegment(Segment seg);

	public abstract List<Segment> getSegments();
	
}
